A test of rstats GIS tools to reproducibly count shrubs



Purpose

Shrub density and spatial patterning of foundation plant species are important components of the landscape that influence ecological interactions. The purpose of this exercise is to examine the capacity for rapid assessment of shrub density near a spatial point in a landscape associated with ecological effect estimates.

Case 1. Animal telemetry data

#packages####
library(tidyverse)
library(adehabitatHR)
library(rgeos)

#telemetry data
data <- read_csv("data/telemetry.relocations.csv")
data
## # A tibble: 1,190 x 16
##    lizard frequency date   time   time.block time.class   lat  long ground
##    <chr>      <int> <chr>  <time> <chr>      <chr>      <dbl> <dbl> <chr> 
##  1 r            760 3-Jul  10:58  morn       AM          35.1 -120. above 
##  2 e            320 1-Jul  10:40  morn       AM          35.1 -120. below 
##  3 e            320 18-Jul 19:46  evening    PM          35.1 -120. below 
##  4 e            320 22-Jun 15:39  afternoon  PM          35.1 -120. below 
##  5 e            320 9-Jul  13:20  afternoon  PM          35.1 -120. below 
##  6 e            320 16-Jun 10:25  morn       AM          35.1 -120. below 
##  7 k            500 22-Jun 08:43  morn       AM          35.1 -120. below 
##  8 k            500 4-Jul  11:57  morn       AM          35.1 -120. below 
##  9 k            500 21-Jun 11:28  morn       AM          35.1 -120. below 
## 10 k            500 3-Jul  08:45  morn       AM          35.1 -120. below 
## # ... with 1,180 more rows, and 7 more variables: mesohabitat <chr>,
## #   microhabitat.simple <chr>, microhabitat1 <chr>, microhabitat2 <chr>,
## #   microhabitat3 <chr>, behavior <chr>, observer <chr>
track.pop <-data
track.pop <- track.pop %>% filter(lizard != "x") #were not 5 relocations for x
coordinates(track.pop) <- ~long+lat
proj4string(track.pop) <- CRS("+proj=longlat") #assign projection and coordinate reference system
track.pop <- spTransform(track.pop, CRS("+proj=utm +zone=10")) #transform

#Minimum Convex Polygon####
#Population
mcp.pop <- adehabitatHR::mcp(track.pop, percent=95, unin = c("m"), unout = c("km2")) #unout is units out
mcp.pop
## Object of class "SpatialPolygonsDataFrame" (package sp):
## 
## Number of SpatialPolygons:  1
## 
## Variables measured:
##   id     area
## a  a 1.351914
mcp.ind <- mcp(track.pop[,1], percent=95, unin = c("m"), unout = c("m")) #adding the [,1] tells it the ID and then does individually instead of collectively.
#mcp.pop <- mcp(track.pop[,1], percent=95, unin = c("km"), unout = c("km")) 
mcp.ind #total area each lizard occupies
## Object of class "SpatialPolygonsDataFrame" (package sp):
## 
## Number of SpatialPolygons:  28
## 
## Variables measured:
##    id         area
## a   a 17556.367432
## aa aa     5.064453
## ab ab 18649.129639
## ac ac  6592.162354
## b   b  1056.970215
## c   c 31882.464600
## ...
#get centroids
cent <- rgeos::gCentroid(mcp.ind)
cent
## SpatialPoints:
##          x       y
## 1 808132.7 3891086
## Coordinate Reference System (CRS) arguments: +proj=utm +zone=10
## +ellps=WGS84
simple.data <- data %>%
  group_by(lizard) %>%
  summarize(x = mean(lat), y = mean(long))

Map

library(raster)
library(sf)
coordinates(simple.data) <- ~y+x
proj4string(simple.data) <- CRS("+proj=longlat") #assign projection and coordinate reference system
sp.data <- spTransform(simple.data, CRS("+proj=utm +zone=10")) #transform
#dat_circles <- st_buffer(sp.data, dist = 1)